package com.flavors.ifly.activity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;

import com.flavors.ifly.hencoderplus.MyButton;
import com.flavors.ifly.hencoderplus.MyLinearlayout;
import com.plat.sdk.R;

/**
 * @author ydong
 * Android ViewGroup事件分发机制
 * <<<总结>>>
 * <p>
 * 1、如果ViewGroup找到了能够处理该事件的View，则直接交给子View处理，自己的onTouchEvent不会被触发；
 * <p>
 * 2、可以通过复写onInterceptTouchEvent(ev)方法，拦截子View的事件（即return true），把事件交给自己处理，则会执行自己对应的onTouchEvent方法
 * <p>
 * 3、子View可以通过调用getParent().requestDisallowInterceptTouchEvent(true);  阻止ViewGroup对其MOVE或者UP事件进行拦截；不会阻止DWON
 * <p>
 * 2020-09-17 20:50:23.710 24989-24989/com.flavors.ifly E/MyLinearlayout: dispatchTouchEvent ACTION_DOWN
 * 2020-09-17 20:50:23.711 24989-24989/com.flavors.ifly E/MyLinearlayout: onInterceptTouchEvent ACTION_DOWN
 * 2020-09-17 20:50:23.711 24989-24989/com.flavors.ifly E/MyButton: dispatchTouchEvent ACTION_DOWN
 * 2020-09-17 20:50:23.711 24989-24989/com.flavors.ifly E/MyButton: onTouchEvent ACTION_DOWN
 * <p>
 * 2020-09-17 20:50:23.715 24989-24989/com.flavors.ifly E/MyLinearlayout: dispatchTouchEvent ACTION_MOVE
 * 2020-09-17 20:50:23.715 24989-24989/com.flavors.ifly E/MyLinearlayout: onInterceptTouchEvent ACTION_MOVE
 * 2020-09-17 20:50:23.715 24989-24989/com.flavors.ifly E/MyButton: dispatchTouchEvent ACTION_MOVE
 * 2020-09-17 20:50:23.715 24989-24989/com.flavors.ifly E/MyButton: onTouchEvent ACTION_MOVE
 * <p>
 * 2020-09-17 20:50:23.716 24989-24989/com.flavors.ifly E/MyLinearlayout: dispatchTouchEvent ACTION_UP
 * 2020-09-17 20:50:23.716 24989-24989/com.flavors.ifly E/MyLinearlayout: onInterceptTouchEvent ACTION_UP
 * 2020-09-17 20:50:23.716 24989-24989/com.flavors.ifly E/MyButton: dispatchTouchEvent ACTION_UP
 * 2020-09-17 20:50:23.716 24989-24989/com.flavors.ifly E/MyButton: onTouchEvent ACTION_UP
 */
public class MyLinearLayoutActivity extends AppCompatActivity {


    private static final String TAG = "MyButton";
    private MyButton myButtonTwo;
    private MyLinearlayout myLinearlayout;

    @SuppressLint("ClickableViewAccessibility")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sample_my_linearlayout);
        initView();
        Log.d("ydong", "onCreate");
    }

    @SuppressLint("ClickableViewAccessibility")
    private void initView() {
        myButtonTwo = findViewById(R.id.myButtonTwo);
        myLinearlayout = findViewById(R.id.myLinearlayout);
        myButtonTwo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
    }


}
